/*==================================================
Project:       Targeting Social Programs
Authors:       Diether W. Beuermann
               Bridget Hoffmann        
               Marco Stampini 
               David L. Vargas
               Diego Vera-Cossio
----------------------------------------------------
Creation Date:    May 2023
Modification Date:   
Do-file version:    01
References:          
Output:             
==================================================*/

** we are only using panel C!

/*==================================================
            0: Program set up
==================================================*/
*Written on STATA 17
drop _all
set varabbrev off	// no variable abbreviations allowed (personal preference)

** source dir
cd "${dir5r}" // graph dir

/*==================================================
            1: load and transformations
==================================================*/

*----------  1.1. Data prep:
use "${dir3r}/03_auxiliar/Budget_estimates.dta", clear

/*==================================================
            4: Make graphs 
==================================================*/

#delimit ;
tw (connected crra year if type_m == "Baseline-10", 
        mcolor(red%90) msym(S) lcolor(red%90) lpattern(solid))
        (connected crra year if type_m == "Baseline-30", 
        mcolor(red%70) msym(S) lcolor(red%70) lpattern(solid))
            (connected crra year if type_m == "Baseline-50", 
        mcolor(red%50) msym(S) lcolor(red%50) lpattern(solid))
            (connected crra year if type_m == "Baseline-70", 
        mcolor(red%30) msym(S) lcolor(red%30) lpattern(solid))
        (connected crra year if type_m == "Baseline-90", 
        mcolor(red%10) msym(S) lcolor(red%10) lpattern(solid))
        (connected crra year if  type_m == "Dynamic-10", 
        mcolor(black%80) msym(D) lcolor(black%80) lpattern(solid))
            (connected crra year if  type_m == "Dynamic-30", 
        mcolor(black%60) msym(D) lcolor(black%60) lpattern(solid))	
        (connected crra year if  type_m == "Dynamic-50", 
        mcolor(black%40) msym(D) lcolor(black%40) lpattern(solid))	
        (connected crra year if  type_m == "Dynamic-70", 
        mcolor(black%20) msym(D) lcolor(black%20) lpattern(solid))
            (connected crra year if  type_m == "Dynamic-90", 
        mcolor(black%20) msym(D) lcolor(black%20) lpattern(solid))
        ,
    legend(order(1 "Benchmark PMT - Coverage 10%"	 2 "30%" 3 "50%" 4 "70%" 5 "90%"	 			
                6 "Dynamic - Coverage 10%" 7 "30%" 8 "50%" 9 "70%" 10 "90%" ) pos(6) row(2)) 
    ytitle("Social Welfare (CRRA {&rho} = 3)")
    xtitle("Year")
    xlabel(2019(1)2021)
    name(B, replace)
;
#delimit cr
graph export "F8_fixed_cov.png", as(png) replace width(1200)
graph export "F8_fixed_cov.pdf", as(pdf) replace 

// ----- Figure A8

#delimit ;
tw (connected exclusion_err year if type_m == "Baseline-10", 
        mcolor(red%90) msym(S) lcolor(red%90) lpattern(solid))
        (connected exclusion_err year if type_m == "Baseline-30", 
        mcolor(red%70) msym(S) lcolor(red%70) lpattern(solid))
            (connected exclusion_err year if type_m == "Baseline-50", 
        mcolor(red%50) msym(S) lcolor(red%50) lpattern(solid))
            (connected exclusion_err year if type_m == "Baseline-70", 
        mcolor(red%30) msym(S) lcolor(red%30) lpattern(solid))
        (connected exclusion_err year if type_m == "Baseline-90", 
        mcolor(red%10) msym(S) lcolor(red%10) lpattern(solid))
        (connected exclusion_err year if  type_m == "Dynamic-10", 
        mcolor(black%80) msym(D) lcolor(black%80) lpattern(solid))
            (connected exclusion_err year if  type_m == "Dynamic-30", 
        mcolor(black%60) msym(D) lcolor(black%60) lpattern(solid))	
        (connected exclusion_err year if  type_m == "Dynamic-50", 
        mcolor(black%40) msym(D) lcolor(black%40) lpattern(solid))	
        (connected exclusion_err year if  type_m == "Dynamic-70", 
        mcolor(black%20) msym(D) lcolor(black%20) lpattern(solid))
            (connected exclusion_err year if  type_m == "Dynamic-90", 
        mcolor(black%20) msym(D) lcolor(black%20) lpattern(solid))
        ,
            legend(order(1 "Benchmark PMT - Coverage 10%"	 2 "30%" 3 "50%" 4 "70%" 5 "90%"	 			
                6 "Dynamic - Coverage 10%" 7 "30%" 8 "50%" 9 "70%" 10 "90%" ) pos(6) row(2)) 
    ytitle("Exclusion error")
    xtitle("Year")
    xlabel(2019(1)2021)
    name(A, replace)
;
#delimit cr
graph export "FA8_a_fixed_cov.png", as(png) replace width(1200)
graph export "FA8_a_fixed_cov.pdf", as(pdf) replace 


#delimit ;
tw (connected inclusion_err year if type_m == "Baseline-10", 
        mcolor(red%90) msym(S) lcolor(red%90) lpattern(solid))
        (connected inclusion_err year if type_m == "Baseline-30", 
        mcolor(red%70) msym(S) lcolor(red%70) lpattern(solid))
            (connected inclusion_err year if type_m == "Baseline-50", 
        mcolor(red%50) msym(S) lcolor(red%50) lpattern(solid))
            (connected inclusion_err year if type_m == "Baseline-70", 
        mcolor(red%30) msym(S) lcolor(red%30) lpattern(solid))
        (connected inclusion_err year if type_m == "Baseline-90", 
        mcolor(red%10) msym(S) lcolor(red%10) lpattern(solid))
        (connected inclusion_err year if  type_m == "Dynamic-10", 
        mcolor(black%80) msym(D) lcolor(black%80) lpattern(solid))
            (connected inclusion_err year if  type_m == "Dynamic-30", 
        mcolor(black%60) msym(D) lcolor(black%60) lpattern(solid))	
        (connected inclusion_err year if  type_m == "Dynamic-50", 
        mcolor(black%40) msym(D) lcolor(black%40) lpattern(solid))	
        (connected inclusion_err year if  type_m == "Dynamic-70", 
        mcolor(black%20) msym(D) lcolor(black%20) lpattern(solid))
            (connected inclusion_err year if  type_m == "Dynamic-90", 
        mcolor(black%20) msym(D) lcolor(black%20) lpattern(solid))
        ,
    legend(order(1 "Benchmark PMT - Coverage 10%"	 2 "30%" 3 "50%" 4 "70%" 5 "90%"	 			
                6 "Dynamic - Coverage 10%" 7 "30%" 8 "50%" 9 "70%" 10 "90%" ) pos(6) row(2))  
    ytitle("Inclusion error")
    xtitle("Year")
    xlabel(2019(1)2021)
    name(B, replace)
;
#delimit cr
graph export "FA8_b_fixed_cov.png", as(png) replace width(1200)
graph export "FA8_b_fixed_cov.pdf", as(pdf) replace 

